package com.example.contestsystem.Dao;

import com.example.contestsystem.Entity.Student;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface StudentRepository extends JpaRepository<Student, Integer>{
    /*

     */

    Student findByStuAccount(int stuAccount);

    @Modifying
    @Transactional
    @Query("UPDATE Student s SET s.stuPassword = :stuPassword WHERE s.stuAccount = :stuAccount")
    void modifyPassword(@Param("stuPassword") String stuPassword, @Param("stuAccount") int stuAccount);

    @Modifying
    @Transactional
    @Query("UPDATE Student s SET s.stuName = :stuName WHERE s.stuAccount = :stuAccount")
    void modifyName(@Param("stuName") String stuName, @Param("stuAccount") int stuAccount);
}
